<script lang="ts" setup>
import { useLayoutMode } from "@/hooks/useLayoutMode"
import logo from "/风车.svg?url"
import logoText1 from "@/assets/layouts/logo-text-1.png?url"
import logoText2 from "@/assets/layouts/logo-text-2.png?url"

interface Props {
  collapse?: boolean
}

const props = withDefaults(defineProps<Props>(), {
  collapse: true
})

const { isLeft, isTop } = useLayoutMode()
</script>

<template>
  <div class="layout-logo-container" :class="{ collapse: props.collapse, 'layout-mode-top': isTop }">
    <transition name="layout-logo-fade">
      <router-link v-if="props.collapse" key="collapse" to="/">
        <img :src="logo" class="layout-logo" />
      </router-link>
      <router-link v-else key="expand" to="/" class="logo-expand-link">
        <img :src="logo" class="layout-logo-text" />
        <span class="logo-text">风起 - A wind stirs</span>
      </router-link>
    </transition>
  </div>
</template>

<style lang="scss" scoped>
.layout-logo-container {
  position: relative;
  width: 100%;
  height: var(--v3-header-height);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  .layout-logo {
    display: none;
  }

  .logo-expand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;

    &:hover {
      transform: scale(1.05);
      opacity: 0.8;
    }
  }

  .layout-logo-text {
    height: 32px;
    width: 32px;
    object-fit: contain;
    flex-shrink: 0;
  }

  .logo-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--el-text-color-primary);
    white-space: nowrap;
    letter-spacing: 0.5px;
  }
}

.layout-mode-top {
  height: var(--v3-navigationbar-height);
}

.collapse {
  .layout-logo {
    width: 32px;
    height: 32px;
    display: block;
    object-fit: contain;
  }

  .logo-expand-link {
    display: none;
  }
}
</style>
